package com.whalehearing.tingyou.api.controller.content;

import com.whalehearing.tingyou.domain.Article;
import com.whalehearing.tingyou.service.IArticleService;
import com.whalehearing.tingyou.common.core.controller.BaseController;
import com.whalehearing.tingyou.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 文章Controller-------------api用于手机app端调用
 *
 * @author zengjun-qxm
 * @date 2024-08-05
 */
@Api(tags="api文章管理")
@RestController
@RequestMapping("/api/content/article")
public class ApiArticleController extends BaseController
{
    @Autowired
    private IArticleService articleService;

    /**
     * 查询已发布的banner
     */
    @ApiOperation("查询已发布的banner列表")
    @PostMapping("/getlist")
    public List<Article> getlist(@RequestBody @Validated Article article)
    {
        //只查询banner
//        article.setCategoryId(12L);
//        article.setState("已发布");
        List<Article> list = articleService.selectArticleList(article);
        return list;
    }

    /**
     * 获取文章详细信息
     */
    @ApiOperation("获取文章详细信息")
    @GetMapping(value = "/{articleId}")
    public AjaxResult getInfo(@PathVariable("articleId") Long articleId)
    {
        return success(articleService.getById(articleId));
    }

}
